<?php
if(!defined('SABLOG_ROOT')) {
	exit('Access Denied');
}

if ($options['enable_trackback']) {
	if ($stats['trackback_count']) {
		$trackback_num = intval($options['trackback_num']);
		if($page) {
			$start_limit = ($page - 1) * $trackback_num;
		} else {
			$start_limit = 0;
			$page = 1;
		}
		$multipage = multi($stats['trackback_count'], $trackback_num, $page, $trackbacks_url);
		$query = $DB->query("SELECT 
			t.articleid,t.title,t.dateline,t.excerpt,t.url,t.blog_name,a.alias,a.title as article
			FROM {$db_prefix}trackbacks t
			LEFT JOIN {$db_prefix}articles a ON a.articleid = t.articleid
			WHERE a.visible='1' AND a.readpassword='' AND t.visible='1' ORDER BY trackbackid DESC LIMIT $start_limit, $trackback_num");

		$trackbackdb=array();
		while ($trackback = $DB->fetch_array($query)) {
			$trackback['article_url'] = getpermalink($trackback['articleid'], $trackback['alias'], 0, sadate('Y/m/d',$article['dateline']));

			$trackback['url'] = sax_stripslashes($trackback['url']);
			$trackback['title'] = sax_stripslashes($trackback['title']);
			$trackback['blog_name'] = sax_stripslashes($trackback['blog_name']);
			$trackback['excerpt'] = sax_stripslashes($trackback['excerpt']);
			$trackback['dateline'] = sadate($options['comment_timeformat'], $trackback['dateline']);
			$trackbackdb[] = $trackback;
		}
		unset($trackback);
		$DB->free_result($query);
	}
} else {
	message('Trackback已经禁用',$referer);
}

$pagefile = 'trackbacks';
$options['title'] = settitle('Trackback');

?>